<script >
$(document).ready(function(){
	$("#dstart, #dend").datepicker({
		dateFormat : "yy-mm"
	});
});
</script>
<style >
table.data tr td,table.data tr th{ font-size: 10px;}
</style>
<form style="padding:5px; width:100%;" id="frm-search" method="post" class="cari" action="<?php echo $own_links;?>search">
	<input type="hidden" name="column" value="all" />
	<img src="<?php echo themeUrl();?>images/cari.png" align="left" />
	<input type="hidden" name="keyword" value=""/>
	<?php if(trim($this->jCfg['user']['level'])=='spvscabang'){?>
	<b><u>Cabang : <?php echo getCabang($this->jCfg['user']['cabang']);?></u></b> 
    <input type="hidden" value="<?php echo $this->jCfg['user']['cabang'];?>" name="column" id="column" />
    <?php }else{ ?>
   	Pilih Nama Cabang : <select name="column" id="column">
		<?php cat_search($cat_search);?>
    </select>
    <?php } ?>
    
    &nbsp;
	Pilih Periode : 
	<input type="text" id="dstart" name="dstart" value="<?php echo $this->jCfg['isearch']['start_date'];?>" size="8" /> s/d 
	<input type="text" name="dend" id="dend" value="<?php echo $this->jCfg['isearch']['end_date'];?>" size="8"/>
	<input type="submit" name="cari" class="btn-cari" value="Cari" />
	<input type="button" onclick="document.location='<?php echo $own_links;?>'" name="reset" class="btn-reset" value="Reset" />
	<?php if(isset($data) && count($data) > 0){ ?>
		<input type="button" name="download-excel" id="donlot'" onclick="_getExcel()" class="btn-cari" value="Download Excel" />
	<?php } ?>
</form>
<div class="clr"></div>
<?php echo isset($paging)?$paging:'';?>
<div class="clr"></div>
<table class="data">
	<tr>
		<th>No</th>  
        <th>Nama</th>
        <th>Alamat</th>
        <th>Tgl Akad</th>
        <th>Tgl Lahir</th>
        <th>USIA</th>
        <th>Periode Pertanggungan</th>
        <th>Uang Pertanggungan</th>
        <th>Tarif Premi (%)</th>    
        <?php if($this->bav_type == 'agunan'){?>
        	<th>Object Pertanggungan</th>
        <?php } ?>  
        <th>Premi</th>
	</tr>
    <?php if(isset($data) && count($data) > 0){
			$no=1;
			foreach($data as $r){
				$premi =  ($r->detail_uang_ptg * $r->detail_periode_ptg * $r->detail_tarif_premi)/100;
		?>
     		<tr>
            	<td><?php echo $no++;?></td>
                <td><?php echo $r->detail_nama;?></td>
                <td><?php echo $r->detail_alamat;?></td>                
                <td><?php echo $r->detail_tglakad;?></td>
                <td><?php echo $r->detail_tgllahir;?></td>
                <td align="center"><?php echo $r->detail_usia;?> Thn</td>
                <td align="center"><?php echo $r->detail_periode_ptg;?></td>
                <td><?php echo myNum($r->detail_uang_ptg);?></td>
                <td><?php echo $r->detail_tarif_premi;?></td>
                <?php if($this->bav_type == 'agunan'){?>
                <td><?php echo $r->detail_obj_ptg;?></td>
                <?php }?>
                <td><?php echo myNum($premi);?></td>
            </tr>   
    <?php } 
	}
	?>
</table>


<?php echo isset($paging)?$paging:'';?>

<script language="javascript">
function _getExcel(){
	col = $('#column').val();
	ds 	= ( $.trim($('#dstart').val()) == "" )?"all":$.trim($('#dstart').val());
	de 	= ( $.trim($('#dend').val()) == "" )?"all":$.trim($('#dend').val());
	url_go = "<?php echo $own_links;?>get_excel/"+col+"/"+ds+"/"+de;
	document.location = url_go;
}

$('.item_submit').change(function(){
	$('#frm-search').submit();
});
</script>